<?php
/*
* Copyright (c) 2010 by Cediti
*
* You may distribute under the terms of either the GNU Lesser General
* Public License or the new BSD License, as specified in the README file.
*/
// created :    09/02/2010
// version :    02/04/2010

class Cmis_Client_Services_Generic_Repository extends Cmis_Services_Abstract implements Cmis_Services_Repository
{
	/**
	 * @var Cmis_Repository_Workspaces
	 */
	protected $_info;

	public function getRepositories($endpoint)
	{
		if (empty($this->_info))
		{
			/* @var $response Cmis_Http_Response */
			$response = $this->getServices()->getProtocolService('Repository')->getRepositories($endpoint);

			if (empty($response) || $response->getHTTPCode() != 200)
			{
				throw new Cmis_Exception_Request_BadHTTPCode($response->getHTTPStatus(), $response->getHTTPCode());
				return null;
			}

			$this->_info = new Cmis_Repository_Workspaces($response->toXml(true));
		}

		return $this->_info;
	}

	public function getRepositoryInfo(Cmis_Repository_Id $repositoryId)
	{
		$repository = $this->getRepositories($this->getServices()->getEndpoint())->getRepositoryById($repositoryId);

		if (is_null($repository))
		{
			throw new Cmis_Exception_Services_Repository_NotFound($repositoryId);
		}

		return $repository;
	}

	public function getTypeChildren(Cmis_Repository_Id $repositoryId, $typeId = null, $includePropertyDefinitions = false, $maxItems = null, $skipCount = null)
	{
		//$cur = $this->_info->getRepositoryById($repositoryId);

		die('-[Must be implemented : ' . __METHOD__ . ' (' . __FILE__ . '#' . __LINE__ . ')]-');
	}

	public function getTypeDescendants(Cmis_Repository_Id $repositoryId, $typeId = null, $depth = null, $includePropertyDefinitions = false)
	{
		die('-[Must be implemented : ' . __METHOD__ . ' (' . __FILE__ . '#' . __LINE__ . ')]-');
	}

	public function getTypeDefinition(Cmis_Repository_Id $repositoryId, $typeId)
	{
		die('-[Must be implemented : ' . __METHOD__ . ' (' . __FILE__ . '#' . __LINE__ . ')]-');
	}
}

# EOF
